﻿@section Css{
    <link type="text/css" href="@Url.Content("~/Content/Css/plugins/sweetalert/sweetalert.css")" rel="stylesheet" />
}
<div class="middle-box text-center loginscreen animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name">King&nbsp;&nbsp;Box</h1>
        </div>
        <h3>欢迎使用后台管理系统</h3>
        <form class="m-t loginform" role="form" action="@Url.Action("Login","Home")">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="用户名" name="userName" required />
            </div>
            <div class="form-group">
                <input type="password" class="form-control" placeholder="密码" name="password" required />
            </div>
            <button type="button" class="btn btn-primary block full-width m-b login">登 录</button>
            <p class="text-muted text-right">
                <a href="#"><small>忘记密码</small></a>
            </p>
        </form>
    </div>
</div>
@section Js{
    <script type="text/javascript" src="@Url.Content("~/Content/Js/Plugins/validate/jquery.validate.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/Js/Plugins/sweetalert/sweetalert.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/Js/Plugins/validate/messages_zh.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/Js/Plugins/layer/layer.min.js")"></script>
    <script type="text/javascript">
        if (window.top !== window.self) { window.top.location = window.location; }

        $(document).keyup(function (event) {
            if (event.keyCode == 13)
                $('.login').trigger("click");
        });

        $(".login").click(function () {
            if (!$(".loginform").valid())
                return;

            var loadIndex = layer.load(1);
            var data = $("form").serializeArray();
            $.post("/Home/Login", data,
                function (res) {
                    layer.close(loadIndex);

                    if (res.Result)
                        window.location.href = '/Home/Index';
                    else {
                        swal("出错了..", res.Message, "error");
                    }
                });
        });
    </script>
}